<script setup lang="ts">
import {computed, inject, ref, watch,reactive} from "vue";
import {Message} from "@arco-design/web-vue";
import AddModal from "@cps/actions/addModal.vue";
import price from "@/api/logistics/price";
const size = ref('small');
const crudRef = inject('crudRef')
const record = inject('record')
const getDictData = inject('getDictData')
const refreshRecode = inject('refreshRecode')
const InfoDataLeft = ref([])
const InfoDataRight = ref([])
const addModalRef = ref()
watch(record, (value) => {
  if(value.id == undefined){
    return;
  } 
  console.log('刷新基础信息--'+record.value.id)
   InfoDataLeft.value =  [
      {label: '名称：', value: record.value.name},
      {label: '收货区域：', value:getDictData('area',record.value.area,crudRef)},
      {label: '服务：', value: getDictData('service',record.value.service,crudRef)},
      {label: '用户等级：', value: getDictData('customer_grade',record.value.customer_grade,crudRef)},
      {label: '用户：', value: getDictData('user',record.value.user,crudRef)},
      {label: '优先级：', value: record.value.level},
      {label: '最小重量：', value: record.value.min_weight},
      {label: '最大重量：', value: record.value.max_weight},
    ]
   InfoDataRight.value = [
      {label: '币种：', value: getDictData('currency',record.value.currency,crudRef)},
      {label: '计价单位：', value: getDictData('charge_mode',record.value.charge_mode,crudRef)},
      {label: '状态：', value: getDictData('status',record.value.status,crudRef)},
      {label: '所属销售：', value: getDictData('seller',record.value.seller,crudRef)},
      {label: '燃油率：', value: record.value.oil_rate},
      {label: '备注：', value: record.value.remark},
    ]
})
const edit = ()=>crudRef.value.editAction(record.value)

</script>
<template>
  <a-grid-item :span="24">
    <add-modal ref="addModalRef"></add-modal>
    <a-collapse :default-active-key="['1']" class="g-collapse">
      <a-collapse-item header="基础信息" key="1" >
        <template #extra>
          <a-button-group>
            <a-button type="primary" size="small" @click.stop="edit()" v-auth="['logistics:price:update']"><icon-edit/>编辑</a-button>
          </a-button-group>
        </template>
        <a-row class="">
          <a-col :span="12">
            <a-descriptions  :data="InfoDataLeft" :size="size" :column="1"  />
          </a-col>
          <a-col :span="12">
            <a-descriptions  :data="InfoDataRight" :size="size" :column="1"  />
          </a-col>
        </a-row>
      </a-collapse-item>
    </a-collapse>
  </a-grid-item>
</template>

<style scoped>

</style>